package org.example.seata.bs.api.feign.product.fallback;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.example.seata.bs.api.dto.order.OrderInfoDto;
import org.example.seata.bs.api.entity.product.Product;
import org.example.seata.bs.api.feign.product.RemoteProductService;
import org.example.seata.common.core.util.ApiResp;

import java.util.List;

/**
 * @author hzq
 * @date 2021/11/18 14:45
 */
@Slf4j
public class RemoteProductServiceFallbackImpl implements RemoteProductService {

    @Setter
    private Throwable cause;

    @Override
    public ApiResp<Product> getById(Integer productId) {
        log.error("查询产品信息失败:{}", cause.getLocalizedMessage());
        return ApiResp.ofFeignError(cause);
    }

    @Override
    public ApiResp<Boolean> minusProductVirtualInventory(List<OrderInfoDto> orderInfoDtoList) {
        log.error("减去产品虚拟库存失败:{}", cause.getLocalizedMessage());
        return ApiResp.ofFeignError(cause);
    }

    @Override
    public ApiResp<Boolean> plusProductVirtualInventory(List<OrderInfoDto> orderInfoDtoList) {
        log.error("加上产品虚拟库存失败:{}", cause.getLocalizedMessage());
        return ApiResp.ofFeignError(cause);
    }
}
